<?php
require(dirname(__FILE__) .'/check.php');
$skin->CheckIframe();


/* **** 版权所有 ****

 程序开发：网钛科技
 网钛CMS官网：http://otcms.com
 网钛IDC官网：http://idccms.com
 ＱＱ：877873666
 微信：tudougeaini
 邮箱：877873666@qq.com

 **** 版权所有 **** */


//打开用户表，并检测用户是否登录
$MB->Open('','login');

$skin->WebTop();

echo('
<script language="javascript" type="text/javascript" src="js/inc/list.js?v='. OT_VERSION .'"></script>
<script language="javascript" type="text/javascript" src="js/banner.js?v='. OT_VERSION .'"></script>
');


switch ($mudi){
	case 'manage':
		$MB->IsSecMenuRight('alertBack',285,$dataType);
		manage();
		break;

	default:
		die('err');
}

$skin->WebBottom();

$MB->Close();
$DB->Close();





function manage(){
	global $DB,$MB,$skin,$mudi,$dataType,$dataTypeCN,$pageCount,$recordCount;

	$dataMode	= OT::GetStr('dataMode');
	$dataModeStr= OT::GetStr('dataModeStr');

	$orderName = OT::ListDefVal(OT::GetStr('orderName'), 'type|theme|url|state|wapState|rank', 'rank');
	$orderSort = OT::ListDefVal(OT::GetStr('orderSort'), 'ASC', 'DESC');

	$sysRow = $DB->GetRow('select TS_isImgBanner,TS_imgBannerH from '. OT_dbPref .'tplSys');
	echo('
	<div style="padding:8px;">
	<form id="sysForm" name="sysForm" method="post" action="tplSys_deal.php?mudi=area" onsubmit="AjaxPostDeal(\'sysForm\');return false;">
	<input type="hidden" id="area" name="area" value="imgBanner" />
		图片轮播：<select name="isImgBanner">
					<option value="1" '. Is::Selected($sysRow['TS_isImgBanner'],1) .'>开启</option>
					<option value="0" '. Is::Selected($sysRow['TS_isImgBanner'],0) .'>关闭</option>
				</select>&ensp;&ensp;&ensp;&ensp;
		图片高度：<input type="text" name="imgBannerH" value="'. $sysRow['TS_imgBannerH'] .'" style="width:60px;" />&ensp;&ensp;&ensp;&ensp;
		<input type="submit" value="保存" />
	</form>
	</div>
	');

	$skin->TableTop2('share_list.gif','',$dataTypeCN .'管理');
	$skin->TableItemTitle('4%,4%,10%,12%,15%,8%,17%,5%,6%,6%,8%','编号,'. $skin->ShowArrow('类型','type',$orderName,$orderSort) .','. $skin->ShowArrow('ID','ID',$orderName,$orderSort) .','. $skin->ShowArrow('名称','theme',$orderName,$orderSort) .',图片,背景色,'. $skin->ShowArrow('网址','url',$orderName,$orderSort) .','. $skin->ShowArrow('排序','rank',$orderName,$orderSort) .','. $skin->ShowArrow('状态','state',$orderName,$orderSort) .','. $skin->ShowArrow('WAP状态','wapState',$orderName,$orderSort) .',修改　删除');

	$pageSize	= $MB->mMbRow['MB_itemNum'];		//每页条数
	$page		= OT::GetInt('page');
	$showRow=$DB->GetLimit('select * from '. OT_dbPref .'banner order by BN_'. $orderName .' '. $orderSort .'',$pageSize,$page);
	if (! $showRow){
		// $skin->TableNoData();
	}else{
		$recordCount=$DB->GetRowCount();
		$pageCount=ceil($recordCount/$pageSize);
		if ($page < 1 || $page > $pageCount){$page=1;}

		echo('
		<tbody class="tabBody padd3td">
		');
		$number=1+($page-1)*$pageSize;
		$rowCount = count($showRow);
		for ($i=0; $i<$rowCount; $i++){
			if ($i % 2 == 1){ $bgcolor='class="tabColorTr"'; }else{ $bgcolor=''; }
			$img = Info::InfoImgUrl($showRow[$i]['BN_img'],ImagesFileAdminDir);

			echo('
			<tr id="data'. $showRow[$i]['BN_ID'] .'" '. $bgcolor .'>
				<td align="center">'. $number .'</td>
				<td align="center">'. $showRow[$i]['BN_ID'] .'</td>
				<td align="center">'. TypeCN($showRow[$i]['BN_type']) .'</td>
				<td align="center">'. $showRow[$i]['BN_theme'] .'</td>
				<td align="center">
					<a href="'. $img .'" target="_blank"><img src="'. $img .'" style="max-width:150px;max-height:150px;" /></a>
				</td>
				<td align="center" style="background:'. $showRow[$i]['BN_bgColor'] .'">'. $showRow[$i]['BN_bgColor'] .'</td>
				<td align="center">'. $showRow[$i]['BN_url'] .'</td>
				<td align="center">'. $showRow[$i]['BN_rank'] .'</td>
				<td align="center">'. Adm::SwitchBtn('banner',$showRow[$i]['BN_ID'],$showRow[$i]['BN_state'],'state') .'</td>
				<td align="center">'. Adm::SwitchBtn('banner',$showRow[$i]['BN_ID'],$showRow[$i]['BN_wapState'],'wapState') .'</td>
				<td align="center">
					<img src="images/img_rev.gif" style="cursor:pointer;" onclick=\'DataDeal.location.href="banner_deal.php?mudi=send&dataType='. $dataType .'&dataTypeCN='. urlencode($dataTypeCN) .'&dataMode='. $dataMode .'&dataModeStr='. $dataModeStr .'&dataID='. $showRow[$i]['BN_ID'] .'&typeNum='. $number .'"\' alt="" />&ensp;&ensp;
					<img src="images/img_del.gif" style="cursor:pointer;" onclick=\'if(confirm("确定删除？")==true){DataDeal.location.href="banner_deal.php?mudi=del&dataType='. $dataType .'&dataTypeCN='. urlencode($dataTypeCN) .'&theme='. urlencode($showRow[$i]['BN_theme']) .'&dataID='. $showRow[$i]['BN_ID'] .'"}\' alt="" />
				</td>
			</tr>
			');
		$number ++;
		}
		echo('
		</tbody>
		');
	}
	unset($showRow);
		
	echo('
	<form method="post" id="dealForm" name="dealForm" action="banner_deal.php?mudi=add" onsubmit="return CheckForm(this)">
	<script language="javascript" type="text/javascript">document.write(\'<input type="hidden" name="backURL" value="\'+ document.location.href +\'">\')</script>
	<input type="hidden" id="dataType" name="dataType" value="'. $dataType .'" />
	<input type="hidden" id="dataTypeCN" name="dataTypeCN" value="'. $dataTypeCN .'" />
	<input type="hidden" id="dataID" name="dataID" value="0" />
	<tr class="tabWriteTr">
		<td id="numID" align="center"><br /></td>
		<td><br /></td>
		<td align="center"><select id="type" name="type"><option value="homeNav">首页导航</option><option value="fix">固定位置</option></select></td>
		<td align="center"><input type="text" id="theme" name="theme" size="25" style="width:120px;" /></td>
		<td align="center"><input type="text" id="img" name="img" size="25" style="width:120px;" /><input type="button" onclick=\'OT_OpenUpImg("input","img","images","&closeWater=1")\' value="上传" /></td>
		<td align="center"><input type="text" id="bgColor" name="bgColor" style="width:52px;" />'. Skin::ColorBox('input','bgColor','theme') .'</td>
		<td align="center"><input type="text" id="url" name="url" size="25" style="width:190px;" value="http://" /></td>
		<td align="center"><input type="text" id="rank" name="rank" size="3" value="'. (intval($DB->GetOne("select max(BN_rank) from ". OT_dbPref ."banner"))+10) .'" onkeyUp="this.value=FiltInt(this.value)" /></td>
		<td align="center"><select id="state" name="state"><option value="1">显示</option><option value="0">隐藏</option></select></td>
		<td align="center"><select id="wapState" name="wapState"><option value="1">显示</option><option value="0">隐藏</option></select></td>
		<td align="center"><input id="subButton" type="image" src="'. AdmTpl::ImgSrc('button_add') .'" /></td>
	</tr>
	</form>
	');

	$skin->TableBottom2($pageCount, $pageSize, $recordCount);

}



function TypeCN($str){
	switch ($str){
		case 'homeNav':		return '首页导航';
		case 'fix':			return '固定位置';
		default :			return '['. $str .']';
	}
}
?>